import { qemscanView, qemscanStart, qemscanDisplay } from '../../service/sample'
import { message } from 'antd';
const Model = {
    namespace: 'qemscan',
    state: {
        list: [1],
        qemscanView: {},
        qemscanIframe: ''
    },
    effects: {
        * getInfo({ payload }, { put, call }) {
            console.log('payload', payload)
            const res = yield call(qemscanView, payload)
            if (res.code == 200) {
                yield put({
                    type: 'saveQemscanView',
                    payload: res.raw
                })
            }
        },
        * qemscanStart({ payload }, { put, call }) {
            const res = yield call(qemscanStart, payload)
            if (res.code == 200) {
                message.success('正在调度算法')
            }
        },

        //展示qemscan
        * qemscanDisplay({ payload }, { put, call }) {
            console.log('12323')
            const res = yield call(qemscanDisplay, payload);
            if (res.code = 200) {
                message.success('获取Qemscan成功')
                yield put({
                    type: 'saveQemScanIframe',
                    payload: res.path
                })
            }
        }
    },
    reducers: {
        saveQemscanView(state, { payload }) {
            return {...state, qemscanView: payload }
        },
        saveQemScanIframe(state, { payload }) {
            return {...state, qemscanIframe: payload }
        }
    }
}

export default Model